﻿using Salient.Web.UI.WebControls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Web.UI;

namespace EnumDataSourceTests
{

    [TestClass()]
    public class EnumDataSourceTest
    {
        /// <summary>
        ///A test for GetDescription
        ///</summary>
        [TestMethod()]
        public void GetDescriptionTest1()
        {
            EnumDataSource target = new EnumDataSource();
            string enumTypeFullName = "Salient.Util.TestEnum01";
            object value = "valueone";
            string expected = "Value One";
            string actual;
            actual = target.GetDescription(enumTypeFullName, value);
            Assert.AreEqual(expected, actual);
            value = Salient.Util.TestEnum01.valueone;
            actual = target.GetDescription(enumTypeFullName, value);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for GetDescription
        ///</summary>
        [TestMethod()]
        public void GetDescriptionTest()
        {
            EnumDataSource target = new EnumDataSource();
            Type enumType = typeof(Salient.Util.TestEnum01);
            object value = Salient.Util.TestEnum01.valueone;
            string expected = "Value One";
            string actual;
            actual = target.GetDescription(enumType, value);
            Assert.AreEqual(expected, actual);

            value = "valueone";
            actual = target.GetDescription(enumType, value);
            Assert.AreEqual(expected, actual);

        }

        /// <summary>
        ///A test for GetValue
        ///</summary>
        [TestMethod()]
        public void GetValueTest1()
        {
            EnumDataSource target = new EnumDataSource();
            string enumTypeFullName = "Salient.Util.TestEnum01";
            string Description = "Value Three";
            Enum expected = Salient.Util.TestEnum01.valuethree;
            Enum actual;
            actual = target.GetValue(enumTypeFullName, Description);
            Assert.AreEqual(expected, actual);

            enumTypeFullName = "Salient.Util.TestEnumFlags01";
            Description = "valuetwo, Value Four";
            expected = Salient.Util.TestEnumFlags01.valuefour | Salient.Util.TestEnumFlags01.valuetwo;

            actual = target.GetValue(enumTypeFullName, Description);
            Assert.AreEqual(expected, actual);

        }

        /// <summary>
        ///A test for GetValue
        ///</summary>
        [TestMethod()]
        public void GetValueTest()
        {
            EnumDataSource target = new EnumDataSource();
            Type enumType = typeof(Salient.Util.TestEnum01);
            string Description = "valueone";
            Enum expected = Salient.Util.TestEnum01.valueone;
            Enum actual;
            actual = target.GetValue(enumType, Description);
            Assert.AreEqual(expected, actual);
            enumType = typeof(Salient.Util.TestEnumFlags01);
            Description = "valueone, Value Four";
            expected = Salient.Util.TestEnumFlags01.valueone | Salient.Util.TestEnumFlags01.valuefour;
            actual = target.GetValue(enumType, Description);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for GetView
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Salient.EnumDataSourceControl20.dll")]
        public void GetViewTest()
        {
            EnumDataSource_Accessor target = new EnumDataSource_Accessor();
            string viewName = "Salient.Util.TestEnum01";
            Salient.Web.UI.WebControls.EnumTypeInfoView actual;
            actual = (Salient.Web.UI.WebControls.EnumTypeInfoView)target.GetView(viewName);
            Assert.AreEqual(3, actual.Values.Count);

        }

    }
}
